/*
 * @Description:
 * @Author: ldx
 * @Date: 2022-09-17 22:04:14
 * @LastEditors: ldx
 * @LastEditTime: 2022-09-24 19:42:19
 */
import axios from '@/utils/axios'

import { Pagination } from '../types'
/** 用户分页列表 */
export async function queryUesrList(
  { current, pageSize }: Pagination,
  params: any
): Promise<any> {
  return axios
    .post<any & Pagination, any>(`/ivr/user/page`, {
      ...params,
      pageSize,
      pageNum: current
    })
    .then((res) => ({
      total: res.data.total,
      list: res.data.records
    }))
}
/** 启用用户 */
export const enableUser = (id: string): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/user/status/enable/${id}`)
}
/** 禁用用户 */
export const disableUser = (id: string): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/user/status/disable/${id}`)
}
/** 重置密码 */
export const passwordReset = (data: {
  id: string
  password: string
}): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/user/password-reset`, data)
}
/** 用户删除 */
export const deleteUser = (id: string): Promise<any> => {
  return axios.post<unknown, any>(`/ivr/user/delete/${id}`)
}
/** 角色分页列表 */
export const queryRole = (params: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/role/simple/list`, {
    ...params,
    pageSize: 1000,
    pageNum: 1
  })
}
/** 用户关联角色 */
export const relateRole = (id: string, data: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/user/relate-role/${id}`, data)
}
/** 用户详情 */
export const queryDetails = (id: string): Promise<any> => {
  return axios.get<any & Pagination, any>(`/ivr/user/details/${id}`)
}
/** 注册用户 */
export const registerUser = (data: any): Promise<any> => {
  return axios.post<any & Pagination, any>(`/ivr/user/register/`, data)
}
